<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html 
     PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
     "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Module: WillPaginate</title>
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  <meta http-equiv="Content-Script-Type" content="text/javascript" />
  <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
  <script type="text/javascript">
  // <![CDATA[

  function popupCode( url ) {
    window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
  }

  function toggleCode( id ) {
    if ( document.getElementById )
      elem = document.getElementById( id );
    else if ( document.all )
      elem = eval( "document.all." + id );
    else
      return false;

    elemStyle = elem.style;
    
    if ( elemStyle.display != "block" ) {
      elemStyle.display = "block"
    } else {
      elemStyle.display = "none"
    }

    return true;
  }
  
  // Make codeblocks hidden by default
  document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
  
  // ]]>
  </script>

</head>
<body>



    <div id="classHeader">
        <table class="header-table">
        <tr class="top-aligned-row">
          <td><strong>Module</strong></td>
          <td class="class-name-in-header">WillPaginate</td>
        </tr>
        <tr class="top-aligned-row">
            <td><strong>In:</strong></td>
            <td>
                <a href="../files/vendor/plugins/will_paginate/lib/will_paginate/collection_rb.html">
                vendor/plugins/will_paginate/lib/will_paginate/collection.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/will_paginate/lib/will_paginate/finder_rb.html">
                vendor/plugins/will_paginate/lib/will_paginate/finder.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/will_paginate/lib/will_paginate/named_scope_rb.html">
                vendor/plugins/will_paginate/lib/will_paginate/named_scope.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/will_paginate/lib/will_paginate/version_rb.html">
                vendor/plugins/will_paginate/lib/will_paginate/version.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/will_paginate/lib/will_paginate/view_helpers_rb.html">
                vendor/plugins/will_paginate/lib/will_paginate/view_helpers.rb
                </a>
        <br />
                <a href="../files/vendor/plugins/will_paginate/lib/will_paginate_rb.html">
                vendor/plugins/will_paginate/lib/will_paginate.rb
                </a>
        <br />
            </td>
        </tr>

        </table>
    </div>
  <!-- banner header -->

  <div id="bodyContent">



  <div id="contextContent">

    <div id="description">
      <h1>You <b>will</b> paginate!</h1>
<p>
First read about <a
href="WillPaginate/Finder/ClassMethods.html">WillPaginate::Finder::ClassMethods</a>,
then see <a
href="WillPaginate/ViewHelpers.html">WillPaginate::ViewHelpers</a>. The
magical array you&#8216;re handling in-between is <a
href="WillPaginate/Collection.html">WillPaginate::Collection</a>.
</p>
<p>
Happy paginating!
</p>

    </div>


   </div>

    <div id="method-list">
      <h3 class="section-bar">Methods</h3>

      <div class="name-list">
      <a href="#M000009">enable</a>&nbsp;&nbsp;
      <a href="#M000010">enable_actionpack</a>&nbsp;&nbsp;
      <a href="#M000011">enable_activerecord</a>&nbsp;&nbsp;
      <a href="#M000012">enable_named_scope</a>&nbsp;&nbsp;
      </div>
    </div>

  </div>


    <!-- if includes -->

    <div id="section">

    <div id="class-list">
      <h3 class="section-bar">Classes and Modules</h3>

      Module <a href="WillPaginate/Finder.html" class="link">WillPaginate::Finder</a><br />
Module <a href="WillPaginate/NamedScope.html" class="link">WillPaginate::NamedScope</a><br />
Module <a href="WillPaginate/VERSION.html" class="link">WillPaginate::VERSION</a><br />
Module <a href="WillPaginate/ViewHelpers.html" class="link">WillPaginate::ViewHelpers</a><br />
Class <a href="WillPaginate/Collection.html" class="link">WillPaginate::Collection</a><br />
Class <a href="WillPaginate/InvalidPage.html" class="link">WillPaginate::InvalidPage</a><br />
Class <a href="WillPaginate/LinkRenderer.html" class="link">WillPaginate::LinkRenderer</a><br />

    </div>




      


    <!-- if method_list -->
    <div id="methods">
      <h3 class="section-bar">Public Class methods</h3>

      <div id="method-M000009" class="method-detail">
        <a name="M000009"></a>

        <div class="method-heading">
          <a href="#M000009" class="method-signature">
          <span class="method-name">enable</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
shortcut for <tt><a
href="WillPaginate.html#M000010">enable_actionpack</a></tt> and <tt><a
href="WillPaginate.html#M000011">enable_activerecord</a></tt> combined
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000009-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000009-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/will_paginate/lib/will_paginate.rb, line 13</span>
13:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enable</span>
14:       <span class="ruby-identifier">enable_actionpack</span>
15:       <span class="ruby-identifier">enable_activerecord</span>
16:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000010" class="method-detail">
        <a name="M000010"></a>

        <div class="method-heading">
          <a href="#M000010" class="method-signature">
          <span class="method-name">enable_actionpack</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
hooks <a href="WillPaginate/ViewHelpers.html">WillPaginate::ViewHelpers</a>
into ActionView::Base
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000010-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000010-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/will_paginate/lib/will_paginate.rb, line 19</span>
19:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enable_actionpack</span>
20:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ActionView</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">instance_methods</span>.<span class="ruby-identifier">include?</span> <span class="ruby-value str">'will_paginate'</span>
21:       <span class="ruby-identifier">require</span> <span class="ruby-value str">'will_paginate/view_helpers'</span>
22:       <span class="ruby-constant">ActionView</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-constant">ViewHelpers</span>
23: 
24:       <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span>(<span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>) <span class="ruby-keyword kw">and</span> <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:rescue_responses</span>
25:         <span class="ruby-constant">ActionController</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">rescue_responses</span>[<span class="ruby-value str">'WillPaginate::InvalidPage'</span>] = <span class="ruby-identifier">:not_found</span>
26:       <span class="ruby-keyword kw">end</span>
27:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000011" class="method-detail">
        <a name="M000011"></a>

        <div class="method-heading">
          <a href="#M000011" class="method-signature">
          <span class="method-name">enable_activerecord</span><span class="method-args">()</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
hooks <a href="WillPaginate/Finder.html">WillPaginate::Finder</a> into
ActiveRecord::Base and classes that deal with associations
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000011-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000011-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/will_paginate/lib/will_paginate.rb, line 31</span>
31:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enable_activerecord</span>
32:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">respond_to?</span> <span class="ruby-identifier">:paginate</span>
33:       <span class="ruby-identifier">require</span> <span class="ruby-value str">'will_paginate/finder'</span>
34:       <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-constant">Finder</span>
35: 
36:       <span class="ruby-comment cmt"># support pagination on associations</span>
37:       <span class="ruby-identifier">a</span> = <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Associations</span>
38:       <span class="ruby-identifier">returning</span>([ <span class="ruby-identifier">a</span><span class="ruby-operator">::</span><span class="ruby-constant">AssociationCollection</span> ]) { <span class="ruby-operator">|</span><span class="ruby-identifier">classes</span><span class="ruby-operator">|</span>
39:         <span class="ruby-comment cmt"># detect http://dev.rubyonrails.org/changeset/9230</span>
40:         <span class="ruby-keyword kw">unless</span> <span class="ruby-identifier">a</span><span class="ruby-operator">::</span><span class="ruby-constant">HasManyThroughAssociation</span>.<span class="ruby-identifier">superclass</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">a</span><span class="ruby-operator">::</span><span class="ruby-constant">HasManyAssociation</span>
41:           <span class="ruby-identifier">classes</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">a</span><span class="ruby-operator">::</span><span class="ruby-constant">HasManyThroughAssociation</span>
42:         <span class="ruby-keyword kw">end</span>
43:       }.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">klass</span><span class="ruby-operator">|</span>
44:         <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-constant">Finder</span><span class="ruby-operator">::</span><span class="ruby-constant">ClassMethods</span>
45:         <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">class_eval</span> { <span class="ruby-identifier">alias_method_chain</span> <span class="ruby-identifier">:method_missing</span>, <span class="ruby-identifier">:paginate</span> }
46:       <span class="ruby-keyword kw">end</span>
47:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>

      <div id="method-M000012" class="method-detail">
        <a name="M000012"></a>

        <div class="method-heading">
          <a href="#M000012" class="method-signature">
          <span class="method-name">enable_named_scope</span><span class="method-args">(patch = true)</span>
          </a>
        </div>
      
        <div class="method-description">
          <p>
Enable named_scope, a feature of Rails 2.1, even if you have older Rails
(tested on Rails 2.0.2 and 1.2.6).
</p>
<p>
You can pass <tt>false</tt> for <tt>patch</tt> parameter to skip
monkeypatching <b>associations</b>. Use this if you feel that
<tt>named_scope</tt> broke has_many, has_many :through or
has_and_belongs_to_many associations in your app. By passing
<tt>false</tt>, you can still use <tt>named_scope</tt> in your models, but
not through associations.
</p>
          <p><a class="source-toggle" href="#"
            onclick="toggleCode('M000012-source');return false;">[Source]</a></p>
          <div class="method-source-code" id="M000012-source">
<pre>
    <span class="ruby-comment cmt"># File vendor/plugins/will_paginate/lib/will_paginate.rb, line 57</span>
57:     <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">enable_named_scope</span>(<span class="ruby-identifier">patch</span> = <span class="ruby-keyword kw">true</span>)
58:       <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">defined?</span> <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">NamedScope</span>
59:       <span class="ruby-identifier">require</span> <span class="ruby-value str">'will_paginate/named_scope'</span>
60:       <span class="ruby-identifier">require</span> <span class="ruby-value str">'will_paginate/named_scope_patch'</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">patch</span>
61: 
62:       <span class="ruby-constant">ActiveRecord</span><span class="ruby-operator">::</span><span class="ruby-constant">Base</span>.<span class="ruby-identifier">send</span> <span class="ruby-identifier">:include</span>, <span class="ruby-constant">WillPaginate</span><span class="ruby-operator">::</span><span class="ruby-constant">NamedScope</span>
63:     <span class="ruby-keyword kw">end</span>
</pre>
          </div>
        </div>
      </div>


    </div>


  </div>


<div id="validator-badges">
  <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
</div>

</body>
</html>